package org.bouscarlo.jj2000.decoding.service;

import android.graphics.Typeface;
import android.os.Parcel;
import android.os.Parcelable;

public class JJ2000Bitmap implements Parcelable {
	public int width;
	public int height;
	public int[] pixels;

	public JJ2000Bitmap(){
	}
	
	public JJ2000Bitmap(int width, int height, int[] pixels){
		this.width=width;
		this.height=height;
		this.pixels=pixels;
	}

    public static final Parcelable.Creator<JJ2000Bitmap> CREATOR = new Parcelable.Creator<JJ2000Bitmap>() {
		@Override
		public JJ2000Bitmap createFromParcel(Parcel in) {
			int width = in.readInt();
			int height = in.readInt();
			int len = in.readInt();
			int pixels[] = null;
			if (len>0){
				pixels = new int[len];
				in.readIntArray(pixels);
			}
			return new JJ2000Bitmap(width,height,pixels);
		}

		/**
		 * Creates an array of our Parcelable object.
		 */
		@Override
		public JJ2000Bitmap[] newArray(int size) {
			return new JJ2000Bitmap[size];
		}
	};


	@Override
	/**
	 * Method which will give additional hints how to process
	 * the parcel. For example there could be multiple
	 * implementations of an Interface which extends the Parcelable
	 * Interface. When such a parcel is received you can use
	 * this to determine which object you need to instantiate.
	 */
	public int describeContents() {
		return 0;
	}

	@Override
	/**
	 * Method which will be called when this object should be
	 * marshalled to a Parcelable object.
	 * Add all required data fields to the parcel in this
	 * method.
	 */
	public void writeToParcel(Parcel outParcel, int flags) {
		outParcel.writeInt(width);
		outParcel.writeInt(height);
		if (pixels!=null){
			outParcel.writeInt(pixels.length);
			outParcel.writeIntArray(pixels);
		} else {
			outParcel.writeInt(0);
		}
	}
}
